﻿using YMJake.Flowable.ExternalWorker.Client.AspNetCore.Pipeline;

namespace YMJake.Flowable.ExternalWorker.Client.Sample.Handlers;

/// <summary>
/// 简单任务处理器
/// </summary>
public class SimpleTaskHandler : IWorkerHandler
{
    private readonly ILogger<SimpleTaskHandler> _logger;

    public SimpleTaskHandler(ILogger<SimpleTaskHandler> logger)
    {
        _logger = logger;
    }

    public async Task HandleAsync(IWorkerPipelineContext context)
    {
        _logger.LogInformation("Executing simple task for job {JobId}", context.Job.Id);
        
        await Task.Delay(500, context.CancellationToken);
        
        _logger.LogInformation("Simple task completed");

        // 自动成功，不需要设置变量
        context.Result = context.ResultBuilder.Success();
    }
}